package com.dkd.logTest.logTest.logger;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Logger;

/*
    Level	intLevel
	OFF	     0
	FATAL	 100
	ERROR	 200
	WARN	 300
	INFO	 400
	DEBUG	 500
	TRACE	 600
	ALL	     Integer.MAX_VALUE
*/

/**
 * 打印日志的工具类
 */

public class LoggerUtil {

	protected static final Level OPERATING = Level.forName("OPERATION", 550);

	/*打印异常日志*/
	@SuppressWarnings("rawtypes")
	public static void  setErrorLog(Class clazz,String msg,Exception e) {
		Logger logger = (Logger) LogManager.getLogger(clazz);
		logger.error(msg+" Unexpected error in ",e);
	}

	/*打印异常日志*/
	@SuppressWarnings("rawtypes")
	public static void  setWarnLog(Class clazz,String msg) {
		Logger logger = (Logger) LogManager.getLogger(clazz);
		logger.warn(msg);
	}

	/*打印debug日志*/
	@SuppressWarnings("rawtypes")
	public static void setInfoLog(Class clazz,String msg) {
		Logger logger = (Logger) LogManager.getLogger(clazz);
		logger.info(msg);
	}

	/*打印debug日志*/
	@SuppressWarnings("rawtypes") 
	public static void setDebugLog(Class clazz,String msg) {
		Logger logger = (Logger) LogManager.getLogger(clazz);
		logger.debug(msg);
	}

	/*打印operating日志*/
	@SuppressWarnings("rawtypes")
	public static void setOperatingLog(Class clazz,String msg) {
		Logger logger = (Logger) LogManager.getLogger(clazz);
		logger.log(OPERATING, msg);
	}


}
